package com.summer.data.jql.concept.exp;


import com.summer.data.Jsql;
import com.summer.data.dialect.Dialect;
import com.summer.data.jql.Context;
import com.summer.data.jql.behavior.FilterAble;
import com.summer.data.jql.concept.Field;
import com.summer.data.table.column.StringColumn;

/**
 * @author 345480567@qq.com
 */
public class LikeFilterExp implements FilterAble {

    Field<String> left;

    String value;

    public LikeFilterExp(Field<String> left, String value) {
        this.left = left;
        this.value = value;
    }

    @Override
    public Jsql toFilterJsql(Context ctx, Dialect dialect) {
        Jsql jsql = Jsql.format("%s like %s", left.toFieldSql(ctx, dialect), dialect.getLikeSql());
        jsql.appendParameters(value);
        return jsql;
    }

}

